<% content_for :page_title do %>
  <%= plural_resource_name(Spree::PaymentMethod) %>
<% end %>

<% content_for :page_actions do %>
  <%= button_link_to Spree.t(:new_payment_method), new_object_url, class: "btn-success", icon: 'add.svg', id: 'admin_new_payment_methods_link' %>
<% end if can? :create, Spree::PaymentMethod %>

<% if @payment_methods.any? %>
<div class="table-responsive">
  <table class="table sortable" id='listing_payment_methods' data-hook data-sortable-link="<%= update_positions_admin_payment_methods_url %>">
    <thead>
      <tr data-hook="admin_payment_methods_index_headers">
        <th></th>
        <th><%= Spree.t(:name) %></th>
        <th><%= Spree.t(:provider) %></th>
        <th class="text-center"><%= Spree.t(:display) %></th>
        <th class="text-center"><%= Spree.t(:active) %></th>
        <th data-hook="admin_payment_methods_index_header_actions" class="actions"></th>
      </tr>
    </thead>
    <tbody id="sortVert">
      <% @payment_methods.each do |method| %>
        <tr id="<%= spree_dom_id method %>" data-hook="admin_payment_methods_index_rows">
          <td class="move-handle text-center">
            <% if can?(:edit, method) %>
              <%= svg_icon name: "sort.svg", width: '18', height: '18' %>
            <% end %>
          </td>
          <td><%= method.name %></td>
          <td><%= method.type.split('::', 3).last %></td>
          <td class="text-center"><%= Spree.t(method.display_on) %></td>
          <td class="text-center"><%= active_badge(method.active) %></td>
          <td data-hook="admin_payment_methods_index_row_actions" class="actions actions-2 text-right">
            <%= link_to_edit(method, no_text: true) if can? :edit, method %>
            <%= link_to_delete(method, no_text: true) if can? :delete, method %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
  </div>
<% else %>
  <div class="alert alert-info no-objects-found">
    <%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::PaymentMethod)) %>,
    <%= link_to(Spree.t(:add_one), new_object_url) if can? :create, Spree::PaymentMethod %>!
  </div>
<% end %>
